package ph.com.gs3.formalistics.model.valueobjects.application;

import org.json.JSONException;
import org.json.JSONObject;

import ph.com.gs3.formalistics.global.constants.NotificationType;

public class RequestNotification extends Notification {

	private String trackingNumber;
	private String formId;

	@Override
	protected void initializeFromJSONImpl(JSONObject json) throws JSONException {
		
		setTrackingNumber(json.getString("request_tracking_number"));
		setFormId(json.getString("related_form_id"));

	}

	@Override
	public String getNotificationText() {

		String notifierName = getNotifier().getDisplayName();

		if (getType() == NotificationType.NEW_REQUEST_FOR_APPROVAL) {
			return String.format("%s sent a new request for your approval: %s", notifierName,
			        getTrackingNumber());
		}

		return null;
	}

	public long getId() {
		return super.getRelatedRecordId();
	}

	public void setId(long id) {
		super.setRelatedRecordId(id);
	}

	public String getTrackingNumber() {
		return trackingNumber;
	}

	public void setTrackingNumber(String trackingNumber) {
		this.trackingNumber = trackingNumber;
	}

	public String getFormId() {
		return formId;
	}

	public void setFormId(String formId) {
		this.formId = formId;
	}

}
